var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var $2ObjUtil = require("ObjUtil");
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_StorageUtil = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
  }
  return babel_createClass(_ctor, null, [{
    key: "getLocalItem",
    value: function getLocalItem(e, t) {
      var n = this._getData(e, t);
      if ("boolean" == typeof t) {
        n = this._toBoolean(n, t);
      } else if ("number" == typeof t) {
        n = this._toNumber(n, t);
      } else if ($2ObjUtil.default.isMap(t)) {
        n = this._toMap(n, t);
      } else {
        "object" == typeof t && (n = this._toJSON(n, t));
      }
      return n;
    }
  }, {
    key: "checkType",
    value: function checkType(e, t) {
      if ($2ObjUtil.default.isObject(t) != $2ObjUtil.default.isObject(e)) {
        return t;
      } else {
        return e;
      }
    }
  }, {
    key: "_setData",
    value: function _setData(e, t) {
      "object" == typeof t && (t = JSON.stringify(t));
      cc.sys.localStorage.setItem(e, t);
    }
  }, {
    key: "_getData",
    value: function _getData(e, t) {
      var n = cc.sys.localStorage.getItem(e);
      null !== n && "null" !== n && "" !== n || null == t || (n = t);
      return n;
    }
  }, {
    key: "_toBoolean",
    value: function _toBoolean(e, t) {
      if ("boolean" == typeof e) {
        return e;
      } else {
        if (null == e || "" == e) {
          return t;
        } else {
          return "false" != e && ("true" == e || undefined);
        }
      }
    }
  }, {
    key: "_toMap",
    value: function _toMap(e, t) {
      return $2ObjUtil.default.Obj2Map(e) || t;
    }
  }, {
    key: "_toNumber",
    value: function _toNumber(e, t) {
      if ("" === e) {
        return t;
      }
      var n = Number(e);
      if (isNaN(n)) {
        return t;
      } else {
        return n;
      }
    }
  }, {
    key: "_toJSON",
    value: function _toJSON(e, t) {
      try {
        var _o97 = JSON.parse(e);
        if ("object" == typeof _o97 && _o97) {
          if ($2ObjUtil.default.isObject(t) == $2ObjUtil.default.isObject(_o97)) {
            return _o97;
          } else {
            if ($2ObjUtil.default.isObject(t)) {
              return $2ObjUtil.default.Arr2Obj(_o97);
            } else {
              return _o97;
            }
          }
        } else {
          return t;
        }
      } catch (n) {
        return t;
      }
    }
  }]);
}();
def_StorageUtil = cc__decorate([ccp_ccclass], def_StorageUtil);
exports.default = def_StorageUtil;